package com.fesine.ssh.service.impl;

import com.fesine.ssh.dao.ProductDao;
import com.fesine.ssh.model.Product;
import com.fesine.ssh.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * Created by Fesine on 2016/2/21.
 */
@Service("productService")
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;
    @Override
    public String add(Product entity) {
        return productDao.save(entity);
    }

    @Override
    public void update(Product entity) {
        productDao.update(entity);
    }

    @Override
    public void delete(String[] prodIds) {
        for (String id : prodIds) {
            productDao.deleteByProdId(id);
        }
    }

    @Override
    public Product findByProdId(String prodId) {
        return productDao.findByProdId(prodId);
    }

    @Override
    public List<Product> findAll() {
        return productDao.findAll();
    }

    @Override
    public List<Product> findAll(int offset, int pageSize) {
        return productDao.findAll(offset,pageSize);
    }

    @Override
    public List<Product> findByEntity(Product entity) {
        return productDao.findByEntity(entity);
    }

    @Override
    public List<Product> findByEntity(Product entity, int offset, int pageSize) {
        return productDao.findByEntity(entity,offset,pageSize);
    }

    @Override
    public List<Product> findByKeyword(String keyword) {
        return productDao.findByKeyword(keyword);
    }
}
